{% extends 'base.html' %}

{% block title %}标签管理 - Will's Blog{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-3">
        {% include 'admin/sidebar.html' %}
    </div>
    
    <div class="col-md-9">
        <div class="d-flex justify-content-between align-items-center mb-4">
            <h1>标签管理</h1>
            <a href="{{ url_for('admin.new_tag') }}" class="btn btn-success">
                <i class="bi bi-tag"></i> 新建标签
            </a>
        </div>
        
        <div class="card">
            <div class="card-body">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>标签名称</th>
                            <th>文章数量</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for tag in tags %}
                        <tr>
                            <td>
                                <a href="{{ url_for('main.tag', slug=tag.slug) }}" target="_blank">
                                    {{ tag.name }}
                                </a>
                            </td>
                            <td>{{ tag.posts.count() }}</td>
                            <td>
                                <div class="btn-group btn-group-sm">
                                    <a href="{{ url_for('admin.edit_tag', id=tag.id) }}" class="btn btn-primary">
                                        <i class="bi bi-pencil"></i>
                                    </a>
                                    <form method="post" action="{{ url_for('admin.delete_tag', id=tag.id) }}" class="d-inline">
                                        <button type="submit" class="btn btn-danger" 
                                                onclick="return confirm('确定要删除这个标签吗？')">
                                            <i class="bi bi-trash"></i>
                                        </button>
                                    </form>
                                </div>
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
{% endblock %}